package com.shanhy.demo.config;

import io.github.lnyocly.ai4j.config.DeepSeekConfig;
import io.github.lnyocly.ai4j.platform.deepseek.chat.DeepSeekChatService;
import io.github.lnyocly.ai4j.service.Configuration;
import okhttp3.OkHttpClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;

@org.springframework.context.annotation.Configuration
public class AiConfig {

    @Value("${ai4j.api.key}")
    private String apiKey;

    @Bean
    public OkHttpClient okHttpClient() {
        return new OkHttpClient.Builder()
                .build();
    }

    @Bean
    public DeepSeekConfig getdeepSeekConfig() {
        DeepSeekConfig config = new DeepSeekConfig();
        config.setApiKey(apiKey);
        return config;
    }


    @Bean
    public DeepSeekChatService getDeepSeekChatService(DeepSeekConfig deepSeekConfig, OkHttpClient okHttpClient) {
        Configuration configuration = new Configuration();
        configuration.setOkHttpClient(okHttpClient);
        configuration.setDeepSeekConfig(deepSeekConfig);
        return new DeepSeekChatService(configuration);
    }

}

